function addLoadEvent(newFunction) {
    var preFunction = window.onload;
    if (typeof preFunction !== "function") {
        console.log("preFunction !== function");
        window.onload = newFunction;
    } else {
        console.log("preFunction === function");
        window.onload = function () {
            preFunction();
            newFunction();
        };
    }
}

function moveElement(elementId, x, y, time) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementId)) return false;
    var element = document.getElementById(elementId);
    var preTop = parseInt(element.style.top);
    var preLeft = parseInt(element.style.left);
    if (preTop === y && preLeft === x) return false;

    var targetTop = preTop;
    var targetLeft = preLeft;
    if (targetTop > y) {
        targetTop--;
    }
    if (targetTop < y) {
        targetTop++;
    }
    if (targetLeft > x) {
        targetLeft--;
    }
    if (targetLeft < x) {
        targetLeft++;
    }
    element.style.position = "absolute";
    element.style.top = targetTop + "px";
    element.style.left = targetLeft + "px";
    var repeat = "moveElement('"+elementId+"',"+x+","+y+","+time+")";
    setTimeout(repeat, time);
}

function insertAfter(newElement, targetElement) {
    var parentNode = targetElement.parentNode;
    if (parentNode.lastChild === targetElement){
        parentNode.appendChild(newElement);
    }else {
       var nextElement =  targetElement.nextSibling;
        parentNode.insertBefore(newElement, nextElement);
    }
}

function addClassName(element, name) {
    if(!element.className){
        element.className = name;
    }else{
        var newClassName = element.className;
        newClassName += " ";
        newClassName += name;
        element.className = newClassName;
    }

}